package jmine.tec.rpc.common.request;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Bean contendo dados sobre uma requição de serviço.
 * 
 * @author lundberg
 */
public class RestRequest {

    private String method;

    private Class<?>[] parameterTypes;

    private Object[] parameters;

    /**
     * Construtor
     */
    public RestRequest() {
    }

    /**
     * Construtor
     * 
     * @param method method
     * @param parameterTypes parameterTypes
     * @param parameters parameters
     */
    public RestRequest(String method, Class<?>[] parameterTypes, Object[] parameters) {
        this.method = method;
        this.parameterTypes = parameterTypes;
        this.parameters = parameters;
    }

    /**
     * @return the method
     */
    public String getMethod() {
        return this.method;
    }

    /**
     * @param method the method to set
     */
    public void setMethod(String method) {
        this.method = method;
    }

    /**
     * @return the parameterTypes
     */
    public Class<?>[] getParameterTypes() {
        return this.parameterTypes;
    }

    /**
     * @param parameterTypes the parameterTypes to set
     */
    public void setParameterTypes(Class<?>[] parameterTypes) {
        this.parameterTypes = parameterTypes;
    }

    /**
     * @return the parameters
     */
    public Object[] getParameters() {
        return this.parameters;
    }

    /**
     * @param parameters the parameters to set
     */
    public void setParameters(Object[] parameters) {
        this.parameters = parameters;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof RestRequest)) {
            return false;
        }
        RestRequest o = (RestRequest) obj;
        return new EqualsBuilder().append(this.method, o.method).append(this.parameterTypes, o.parameterTypes)
                .append(this.parameters, o.parameters).isEquals();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(this.method).append(this.parameterTypes).append(this.parameters).toHashCode();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
